package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import android.util.Log;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IBaseRepository;
import com.itboye.mengwu.data.interfaces.ILunBo;
import com.itboye.mengwu.data.model.LunBoModel;
import com.itboye.mengwu.data.repository.LunBoRepository;

public class LunBoPresenter extends BasePresenter implements
		IBaseRepository<LunBoModel> {

	public static final String BannerSuccessEvent = MainPresenter.class
			.getName() + "_Banner_success";
	public static final String BannerFailEvent = MainPresenter.class.getName()
			+ "_Banner_failure";

	public LunBoPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(LunBoModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(LunBoModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(LunBoModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(LunBoModel model) {
		// TODO Auto-generated method stub
		ILunBo<LunBoModel> banner = new LunBoRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(BannerSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(BannerFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getInfo(model);// (phoneNumber,codeType);
	}

	@Override
	public List<LunBoModel> queryYouHuiQuan(LunBoModel model) {
		// TODO Auto-generated method stub
		return null;
	}

	public void LunBo( int position) {
		ILunBo<LunBoModel> banner = new LunBoRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(BannerSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(BannerFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.LunBo(position);// (phoneNumber,codeType);
	}

}
